import http from '../../utils/request'
Page({
  data: {
    openAttr: true,
    noCollectImage: "/static/images/icon_collect.png",
    hasCollectImage: "/static/images/icon_collect_checked.png",
    collectBackImage: "/static/images/icon_collect.png",
    info:{},
    gallery:[],
    attribute:[],
    userHasCollect:'',
    issue:[],
    comment:{},
    brand:[],
    specificationList:[],
    productList:[],
    goods_specification_ids:[]
  },
  // 获取商品数据信息
  async loadGoodsInfo(id){
    let {
      info,
      gallery,
      attribute,
      userHasCollect,
      issue,
      comment,
      brand,
      specificationList,
      productList,
      goods_specification_ids
     } = await  http.get('/goods/detail?id='+id)
     this.setData({
      info,
      gallery,
      attribute,
      userHasCollect,
      issue,
      comment,
      brand,
      specificationList,
      productList,
      goods_specification_ids
     })
  },
  // 打开属性选择
  switchAttrPop(){
    this.setData({
      openAttr:true
    })
  },
  onLoad: function (options) {
    this.loadGoodsInfo(options.id)
  },
  onReady: function () {
    // 页面渲染完成

  },
  onShow: function () {
    // 页面显示

  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭

  },
  // 打开规格参数
  switchAttrPop: function () {
    if (this.data.openAttr == false) {
      this.setData({
        openAttr: !this.data.openAttr
      });
    }
  },
  // 关闭规格参数
  closeAttr: function () {
    this.setData({
      openAttr: false,
    });
  }
})